﻿package com.victim.snake.graphics.mainClass {
	
	import com.victim.snake.util.GraphicsToll;
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.display.LineScaleMode;
    import flash.display.CapsStyle;
    import flash.display.JointStyle;
    import flash.text.TextField;
    import flash.events.MouseEvent;
	
	//房间列表类	暂时无用或以过时
	public class RoomListSprite extends Sprite{
		
		private var count:uint=0;	//当前列表项目条数		
		private var itemHeight:int=20;	//当前列表项的高
		
		
		
		public function RoomListSprite() {			
			
			graphics.lineStyle(0, 0xcccccc, 1, false, LineScaleMode.VERTICAL,CapsStyle.NONE, JointStyle.MITER, 10);
			
			//标题栏
			GraphicsToll.drawRectBorder(graphics,0,0,50,20);	//房间id 房间号
			GraphicsToll.drawRectBorder(graphics,50,0,400,20);	//房间名
			GraphicsToll.drawRectBorder(graphics,450,0,50,20);	//玩家数
			GraphicsToll.drawRectBorder(graphics,500,0,120,20);	//房主
			
			
			//房间号标题
			var roomIdTitle:TextField=new TextField();
			roomIdTitle.selectable=false;
			roomIdTitle.text="房间号";
			roomIdTitle.x=6;
			roomIdTitle.y=1;
			this.addChildAt(roomIdTitle,0);
			
			//房间名标题
			var roomTitleTitle:TextField=new TextField();
			roomTitleTitle.selectable=false;
			roomTitleTitle.text="房间名";
			roomTitleTitle.x=220;
			roomTitleTitle.y=1;
			this.addChildAt(roomTitleTitle,1);
			
			//玩家数标题
			var roomPlayerCountTitle:TextField=new TextField();
			roomPlayerCountTitle.selectable=false;
			roomPlayerCountTitle.text="人数";
			roomPlayerCountTitle.x=462;
			roomPlayerCountTitle.y=1;
			this.addChildAt(roomPlayerCountTitle,2);
			
			//房主标题
			var roomMasterTitle:TextField=new TextField();
			roomMasterTitle.selectable=false;
			roomMasterTitle.text="房主";
			roomMasterTitle.x=544;
			roomMasterTitle.y=1;
			this.addChildAt(roomMasterTitle,2);
			
			
		}
		
		
		
		//添加列表项
		public function addItem(id:int,roomName:String,playerCount:int,masterPlayerName:String,itemValue:int):void{
			//边框
			//trace(getY());
			GraphicsToll.drawRectBorder(graphics,0,getY(),50,20);	//房间id 房间号
			GraphicsToll.drawRectBorder(graphics,50,getY(),400,20);	//房间名
			GraphicsToll.drawRectBorder(graphics,450,getY(),50,20);	//玩家数
			GraphicsToll.drawRectBorder(graphics,500,getY(),120,20);	//房主
			
			//房间号
			var roomId:TextField=new TextField();
			roomId.selectable=false;
			roomId.text=id+"";
			roomId.x=6;
			roomId.y=getY()+1;
			this.addChildAt(roomId,0);
			
			//房间名
			var roomTitle:TextField=new TextField();
			roomTitle.selectable=false;
			roomTitle.text=roomName;
			roomTitle.x=56;
			roomTitle.y=getY()+1;
			this.addChildAt(roomTitle,1);
			
			//玩家数
			var roomPlayerCount:TextField=new TextField();
			roomPlayerCount.selectable=false;
			roomPlayerCount.text=playerCount+"";
			roomPlayerCount.x=456;
			roomPlayerCount.y=getY()+1;
			this.addChildAt(roomPlayerCount,2);
		
			//房主
			var roomMaster:TextField=new TextField();
			roomMaster.selectable=false;
			roomMaster.text=masterPlayerName;
			roomMaster.x=506;
			roomMaster.y=getY()+1;
			this.addChildAt(roomMaster,2);
			
			count++;
			
		}
		
		//返回通过当前列表项计算后的Y值
		public function getY():int{
			return itemHeight+count*20;
		}

	}
	
}
